package com.ag.lwc.action;

import java.util.Map;

import javax.annotation.Resource;

import org.apache.struts2.interceptor.SessionAware;

import com.ag.bean.TbUser;
import com.ag.common.BaseAction;
import com.ag.common.IPermissionService;
import com.ag.lwc.service.CtiIPService;

/**
 * 坐席登录的action
 * 获取坐席的初始化信息
 * @author user
 *
 */
public class AgentLoginAction extends BaseAction implements SessionAware{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -9015457612780481023L;
	private String servIP;		//服务器ip地址
	private String deviceId; 	//设备id
	private String agentId;		//坐席id
	private String password;	//坐席登录密码
	private String queue;		//队列
	private CtiIPService ctiipservice; 		//返回cti服务器ip用
	

	
	/**
	 * 返回当前用户
	 * @return
	 */
	public TbUser currentUser()					
	{
		TbUser	user=null; 
	
		user = new TbUser();
		user.setUCtiId("6000");
		user.setUCtiNumber("8004");
		user.setUCtiQueue("9991");
		user.setUCtiPsw("123456");
		
		user = pms.getCurrentUser(sessionMap);			//获取当前用户
	//	System.out.println("当前用户的id："+user.getUId());
		
		return user;
	}
	
	/**
	 * 坐席登录
	 */
	public String execute()
	{
		TbUser user = this.currentUser();
		servIP = ctiipservice.getServIP();
		System.out.println("AgentLoginAction:  servIP: "+servIP);
		deviceId = user.getUCtiNumber();
		agentId = user.getUCtiId();
		queue = user.getUCtiQueue();
		password = user.getUCtiPsw();
		return "agentLogin";
	}

	public String getServIP() {
		return servIP;
	}

	public void setServIP(String servIP) {
		this.servIP = servIP;
	}

	public String getDeviceId() {
		return deviceId;
	}

	public void setDeviceId(String deviceId) {
		this.deviceId = deviceId;
	}

	public String getAgentId() {
		return agentId;
	}

	public void setAgentId(String agentId) {
		this.agentId = agentId;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getQueue() {
		return queue;
	}

	public void setQueue(String queue) {
		this.queue = queue;
	}

	public CtiIPService getCtiipservice() {
		return ctiipservice;
	}

	public void setCtiipservice(CtiIPService ctiipservice) {
		this.ctiipservice = ctiipservice;
	}

	public Map<String, Object> getSessionMap() {
		return sessionMap;
	}

	public void setSessionMap(Map<String, Object> sessionMap) {
		this.sessionMap = sessionMap;
	}

	public IPermissionService getPms() {
		return pms;
	}

	public void setPms(IPermissionService pms) {
		this.pms = pms;
	}
	
	private Map<String, Object> sessionMap;						//用来获取当前用户
	@Resource(name = "PermissionServiceImpl")
	private IPermissionService pms;
	@Override
	public void setSession(Map<String, Object> arg0) {
		this.sessionMap = arg0;
		
	}
}
